import { JsEnvExample5, UnityEngine } from "csharp";
import { $typeof } from "puerts";

const component = UnityEngine.GameObject.FindObjectOfType($typeof(JsEnvExample5)) as JsEnvExample5;

const gameObject = UnityEngine.GameObject.Find("Cube");

component.add_onClick1(()=>{
    console.log("ts:Click 1 Lambda call");
    let v1 = new UnityEngine.Vector3(1,1,1);
    let v2 = UnityEngine.Vector3.op_Addition(v1,new UnityEngine.Vector3(1,2,3));
    console.log(`Vector add out:x=${v2.x},y=${v2.y},z=${v2.z}`);    
});

const funCall = function(){
    console.log("ts:Click 1 funtion call");
    const d = Math.random() * 3 + 1;
    gameObject.transform.localScale = UnityEngine.Vector3.op_Multiply(UnityEngine.Vector3.one,d);
}
component.add_onClick1(funCall);

component.add_onClick2((s)=>{
    console.log("ts:Click 2 , s=" + s);
    const a = parseInt(s);
    const r1 = gameObject.transform.localEulerAngles;
    const r2 = UnityEngine.Vector3.op_Subtraction(r1,new UnityEngine.Vector3(0,a,0));
    gameObject.transform.localEulerAngles = r2;
})

